package com.openbravo.bean.sales;

import java.util.HashMap;

import e.odbo.data.bean.I_AutoGeneratorStringKey;
import e.odbo.data.bean.I_BaseBean;

import com.openbravo.bean.Product;

public class ShoppingCart implements I_BaseBean<String>,I_AutoGeneratorStringKey{
	/**
	 * 
	 */
	private static final long serialVersionUID = 2364524379279002627L;
	public String id;
	public String customerId;
	public HashMap<Product,Double> lines;

	public ShoppingCart(String customerId) {
	    this.customerId=customerId;
	    lines=new HashMap<Product,Double>();
	}

	public ShoppingCart() {
		this(null);
	}

	public void clear(){
		lines=new HashMap<Product,Double>();
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	public HashMap<Product, Double> getLines() {
		return lines;
	}

	public void setLines(HashMap<Product, Double> lines) {
		this.lines = lines;
	}

	@Override
	public String getKey() {
		return id;
	}

	@Override
	public void setKey(String key) {
		this.id=key;
	}
	
    public void addShoppingProduct(Product obj,double d){
    	if(d==0.0)
    		lines.remove(obj);
    	else
    	    lines.put(obj, d);
    }
    
    public Double getUnit(Product obj){
    	return lines.get(obj);
    }
}
